package com.first.dao.impl;

import com.first.dao.BTypeDao;
import com.first.entity.BType;
import com.first.util.DBUtil;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class BTypeDaoImpl implements BTypeDao {
    @Override
    public List<Map> getBookType() {
        String sql="select *from b_type";
        return DBUtil.queryListMap(sql);
    }

    @Override
    public int addBookType(BType bType) {
        String sql="insert into b_type values(null,?)";
        return DBUtil.update(sql,bType.getType());
    }

    @Override
    public int updateBookType(BType bType) {
        String sql="update b_type set type=? where typeid=? ";
        return DBUtil.update(sql,bType.getType(),bType.getTypeid());
    }

    @Override
    public int delBookType(Integer id) {
        String sql="delete from b_type where id=?";
        return DBUtil.update(sql,id);
    }
}
